﻿<?php
	@session_start();
	include("../../connect/connect_mysql.php");
	$act= $_POST['act'];
	
	if ($act == 'edit_content'){
		$page_id = $_POST['page_id'];
		$d = $_POST['date'];
		$id = $_POST['id'];
		$info = $_POST['info'];
		$info=str_replace(chr(13),"",$info);
		$info=str_replace("\n",".-",$info);
		$query = "UPDATE `content` SET `page_id`= '$page_id' , `date`='$d', `info`='$info' WHERE `content_id`='$id';";
		mysql_query ("SET NAMES 'utf8'");
		mysql_query($query);
		echo 1;
	}
	if ($act== 'delete_content'){
		$page_id = $_POST['page_id'];
		$ids = $_POST['ids'];
		$query = "UPDATE `content` SET `is_deleted`= '1' WHERE page_id = $page_id and content_id IN ($ids);";
		mysql_query ("SET NAMES 'utf8'");
		mysql_query($query);
		echo 1;
	}
	
	if($act== 'select_content'){
		$id = $_POST['id'];
		$page_id = $_POST['page_id'];
		$query = "UPDATE `content` SET `flag`= '0' WHERE page_id = '$page_id' and content_id <> '$id' ;";
		mysql_query ("SET NAMES 'utf8'");
		mysql_query($query);
		$query = "UPDATE `content` SET `flag`= '1' WHERE page_id = '$page_id' and content_id = '$id' ;";
		mysql_query ("SET NAMES 'utf8'");
		mysql_query($query);
		echo 1;
		}				
		
	if ($act== 'innit'){
		$id = $_POST['id'];
		$page_id = $_POST['page_id'];
		$query = "SELECT * FROM content WHERE page_id='$page_id' and content_id = '$id'";
		mysql_query ("SET NAMES 'utf8'");
	 	$rs = mysql_query($query) or die(mysql_error());
	 	if ($rs){
	 		echo mysql_fetch_full_result_array($rs);
	 	}
	}
?>
	